package com.alks.entity.data.entity.dispatch;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDate;
import java.time.Period;
import java.time.ZoneId;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class Employee implements Serializable {

    private String companyId;
    private String idNo;
    private String deptNo;
    private String deptName;
    private String name;
    private @NotBlank(
            message = "性别不能为空") String sex;
    private @NotBlank(
            message = "职务不能为空") String position;
    private String workType;
    private @NotBlank(
            message = "电话不能为空"
    ) String mobileNo;
    private @NotBlank(
            message = "地址不能为空"

    ) String address;
    @JsonFormat(
            pattern = "yyyy-MM-dd"
    )
    private @NotNull(
            message = "进厂日期不能为空"
    ) Date dateIn;
    private @NotNull(
            message = "是否签约不能为空"
    ) String contract;
    private String sysUser;
    private Date sysDate;
    private String cfmFlag;
    private String cfmUser;
    private Date cfmDate;
    private @NotNull(
            message = "计件/计时不能为空"
    ) String calcType;
    private @NotNull(
            message = "工号不能为空"
    ) String workerId;
    private String education;
    private String married;
    private String childFlag;
    private String nation;
    private String contactPerson;
    private String contactPhone;
    private String addressNow;
    private Date contractDate;
    private String parentDeptName;
    private int status = 1;
    private String remark;
    private String delReason;
    private Date delDate;
    private String bankCardName;
    private String bankCardId;
    private String bankCardUser;
    @JsonIgnore
    private String searchKey;
    @JsonIgnore
    private Map<String, Object> params;
    private static final long serialVersionUID = 1L;

    public Employee() {
    }


    public String getCompanyId() {
        return this.companyId;
    }

    public void setCompanyId(String companyId) {
        this.companyId = companyId;
    }

    public String getIdNo() {
        return this.idNo;
    }

    public void setIdNo(String idNo) {
        this.idNo = idNo;
    }

    public String getDeptNo() {
        return this.deptNo;
    }

    public void setDeptNo(String deptNo) {
        this.deptNo = deptNo == null ? null : deptNo.trim();
    }

    public String getDeptName() {
        return this.deptName;
    }

    public void setDeptName(String deptName) {
        this.deptName = deptName == null ? null : deptName.trim();
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name == null ? null : name.trim();
    }

    public String getSex() {
        return this.sex;
    }

    public void setSex(String sex) {
        this.sex = sex == null ? null : sex.trim();
    }

    public String getPosition() {
        return this.position;
    }

    public void setPosition(String position) {
        this.position = position == null ? null : position.trim();
    }

    public String getWorkType() {
        return this.workType;
    }

    public void setWorkType(String workType) {
        this.workType = workType == null ? null : workType.trim();
    }

    public String getMobileNo() {
        return this.mobileNo;
    }

    public void setMobileNo(String mobileNo) {
        this.mobileNo = mobileNo == null ? null : mobileNo.trim();
    }

    public String getAddress() {
        return this.address;
    }

    public void setAddress(String address) {
        this.address = address == null ? null : address.trim();
    }

    public Date getDateIn() {
        return this.dateIn;
    }

    public void setDateIn(Date dateIn) {
        this.dateIn = dateIn;
    }

    public String getContract() {
        return this.contract;
    }

    public void setContract(String contract) {
        this.contract = contract == null ? null : contract.trim();
    }

    public String getSysUser() {
        return this.sysUser;
    }

    public void setSysUser(String sysUser) {
        this.sysUser = sysUser == null ? null : sysUser.trim();
    }

    public Date getSysDate() {
        return this.sysDate;
    }

    public void setSysDate(Date sysDate) {
        this.sysDate = sysDate;
    }

    public String getCfmFlag() {
        return this.cfmFlag;
    }

    public void setCfmFlag(String cfmFlag) {
        this.cfmFlag = cfmFlag == null ? null : cfmFlag.trim();
    }

    public String getCfmUser() {
        return this.cfmUser;
    }

    public void setCfmUser(String cfmUser) {
        this.cfmUser = cfmUser == null ? null : cfmUser.trim();
    }

    public Date getCfmDate() {
        return this.cfmDate;
    }

    public void setCfmDate(Date cfmDate) {
        this.cfmDate = cfmDate;
    }

    public String getCalcType() {
        return this.calcType;
    }

    public void setCalcType(String calcType) {
        this.calcType = calcType == null ? null : calcType.trim();
    }

    public String getWorkerId() {
        return this.workerId;
    }

    public void setWorkerId(String workerId) {
        this.workerId = workerId == null ? null : workerId.trim();
    }

    public String getEducation() {
        return this.education;
    }

    public void setEducation(String education) {
        this.education = education == null ? null : education.trim();
    }

    public String getMarried() {
        return this.married;
    }

    public void setMarried(String married) {
        this.married = married == null ? null : married.trim();
    }

    public String getChildFlag() {
        return this.childFlag;
    }

    public void setChildFlag(String childFlag) {
        this.childFlag = childFlag == null ? null : childFlag.trim();
    }

    public String getNation() {
        return this.nation;
    }

    public void setNation(String nation) {
        this.nation = nation == null ? null : nation.trim();
    }

    public String getContactPerson() {
        return this.contactPerson;
    }

    public void setContactPerson(String contactPerson) {
        this.contactPerson = contactPerson == null ? null : contactPerson.trim();
    }

    public String getContactPhone() {
        return this.contactPhone;
    }

    public void setContactPhone(String contactPhone) {
        this.contactPhone = contactPhone == null ? null : contactPhone.trim();
    }

    public String getAddressNow() {
        return this.addressNow;
    }

    public void setAddressNow(String addressNow) {
        this.addressNow = addressNow == null ? null : addressNow.trim();
    }

    public Date getContractDate() {
        return this.contractDate;
    }

    public void setContractDate(Date contractDate) {
        this.contractDate = contractDate;
    }

    public String getSearchKey() {
        return this.searchKey;
    }

    public void setSearchKey(String searchKey) {
        this.searchKey = searchKey;
    }

    public Map<String, Object> getParams() {
        if (this.params == null) {
            this.params = new HashMap();
        }

        return this.params;
    }

    public void setParams(Map<String, Object> params) {
        this.params = params;
    }

    @JsonIgnore
    public int getWorkAge() {
        if (this.dateIn == null) {
            return 0;
        } else {
            ZoneId zoneId = ZoneId.systemDefault();
            Period p = Period.between(this.dateIn.toInstant().atZone(zoneId).toLocalDate(), LocalDate.now());
            return p.getYears();
        }
    }

    @JsonIgnore
    public String getChildFlagStr() {
        return "Y".equals(this.childFlag) ? "是" : null;
    }

    @JsonIgnore
    public String getMarriedStr() {
        return "Y".equals(this.married) ? "已婚" : "未婚";
    }

    public String getBirthday() {
        if (this.idNo != null && this.idNo.length() >= 14) {
            String year = this.idNo.substring(6, 10);
            String month = this.idNo.substring(10, 12);
            String day = this.idNo.substring(12, 14);
            return StringUtils.format("{}-{}-{}", new Object[]{year, month, day});
        } else {
            return null;
        }
    }

    public String getParentDeptName() {
        return this.parentDeptName;
    }

    public void setParentDeptName(String parentDeptName) {
        this.parentDeptName = parentDeptName;
    }

    public int getStatus() {
        return this.status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getBankCardName() {
        return this.bankCardName;
    }

    public void setBankCardName(String bankCardName) {
        this.bankCardName = bankCardName;
    }

    public String getBankCardId() {
        return this.bankCardId;
    }

    public void setBankCardId(String bankCardId) {
        this.bankCardId = bankCardId;
    }

    public String getBankCardUser() {
        return this.bankCardUser;
    }

    public void setBankCardUser(String bankCardUser) {
        this.bankCardUser = bankCardUser;
    }

    public String getRemark() {
        return this.remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Date getDelDate() {
        return this.delDate;
    }

    public void setDelDate(Date delDate) {
        this.delDate = delDate;
    }

    public String getDelReason() {
        return this.delReason;
    }

    public void setDelReason(String delReason) {
        this.delReason = delReason;
    }
}
